home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 3032.ZIP / RLIB20.ZIP / RL_PATHT.PRG < prev    next >
Text File  |  1989-02-18  |  2KB  |  38 lines

  1. * Function: PATHTO
  2. * Author..: Richard Low
  3. * Syntax..: PATHTO(exp<C>)  Where exp<C> is name of file to find path to.
  4. * Usage...: To find the DOS path pointing to a file.
  5. * Returns.: DOS path pointing to filename specified by exp<C>, or a NULL
  6. *           string if the file was not found in any of the paths.
  7. *
  8.  
  9. FUNCTION PATHTO
  10. PARAMETER p_filename
  11. PRIVATE f_dospath, f_path
  12.  
  13. f_dospath = GETE('PATH')                                              && get dos's path from environment (in EXTEND.LIB)
  14. DO WHILE LEN(TRIM(f_dospath)) > 0                                     && parse for path to help files
  15.  
  16.    IF ';' $ f_dospath                                                 && if a semicolon is found in path
  17.       f_path = TRIM(SUBSTR(f_dospath,1,AT(';',f_dospath)-1))          && parse each section of the path
  18.    ELSE                                                               && otherwise
  19.       f_path = TRIM(f_dospath)                                        && only one path in the path
  20.    ENDIF
  21.  
  22.    IF FILE( f_path + '\' + p_filename )                               && found it
  23.       RETURN (f_path + '\')
  24.    ENDIF
  25.  
  26.    IF ';' $ f_dospath
  27.       f_dospath = TRIM(SUBSTR(f_dospath,AT(';',f_dospath)))           && snip off beginning of path before semicolon
  28.       IF LEN(f_dospath) = 1                                           && only a semicolon left
  29.          EXIT                                                         && quit looking
  30.       ENDIF                                                           && otherwise
  31.       f_dospath = SUBSTR(f_dospath,2)                                 && snip off the leading semicolon
  32.    ELSE
  33.       EXIT
  34.    ENDIF
  35.  
  36. ENDDO
  37. RETURN ('')
  38.